package com.servlet.JeuDeLaBiere;

import java.io.IOException;
import java.io.PrintWriter;

import javax.servlet.ServletContext;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import com.servlet.JeuDeLaBiere.Model.Main;
import com.servlet.JeuDeLaBiere.Model.Partie;

public class ServletPassageCommande extends HttpServlet {
	public void doGet(HttpServletRequest req, HttpServletResponse resp)
			throws ServletException, IOException {
		ServletContext context = this.getServletContext();
		String nomPartie = req.getParameter("nomPartie");
		Partie maPartie = ((Main)context.getAttribute("Serveur")).getPartie(nomPartie);
		int position = maPartie.getChaineLog().rangJoueur(req.getParameter("nomJoueur"));
		maPartie.getChaineLog().getEntiteLog(position).setCommandeEnv(Integer.parseInt(req.getParameter("commande")), maPartie.getTour());
		
	}
protected void doPost(HttpServletRequest req, HttpServletResponse resp)
			throws ServletException, IOException {
		doGet(req, resp);
	}
}
